package data

import (
	"sync"
)

const _bv bool = true

// 多读少写, 场景
type MapPtIdStruct struct {
	m sync.Map
}

func (a *MapPtIdStruct) Add(ptId string) {
	a.m.Store(ptId, _bv)
}

func (a *MapPtIdStruct) Exist(ptId string) bool {
	_, ok := a.m.Load(ptId)
	// strValue := value.(string) 类型断言
	return ok
}

// 废弃
func (a *MapPtIdStruct) Array() []string {
	ptIds := make([]string, 0)
	a.m.Range(func(k, v any) bool {
		ptId := k.(string)
		ptIds = append(ptIds, ptId)
		return true
	})
	return ptIds
}
